/*
 * @Descripttion: 
 * @version: 
 * @Author: Ansel
 * @Date: 2020-05-17 12:09:11
 * @LastEditors: Ansel
 * @LastEditTime: 2020-05-17 12:15:44
 */ 
function clone(obj){
    if(Array.isArray(obj)){
        let res = [];
        for(let i = 0;i < obj.length;i ++){
            res.push(clone(obj[i]));
        }
        return res;
    }else if(typeof obj == "object"){
        let o = {};
        for(let key in obj){
            o[key] = clone(obj[key]);
        }
        return o;
    }else{
        return obj;
    }
}

var obj = {a:1,b:2,c:[1,2,3,[1,2],{c:1}]};
var o = clone(obj);
console.log(o);